<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8" />
	<title>社团管理</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="css/swiper.min.css" />
	<link href="http://cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet" media="all">
	<link href="css/bootstrap-touch-slider.css" rel="stylesheet" media="all">
	<link rel="stylesheet" type="text/css" href="css/pc.css" />
	<link rel="stylesheet" type="text/css" media="screen and (max-width:1200px)" href="css/ipad.css">
	<link rel="stylesheet" type="text/css" media="screen and (max-width:768px)" href="css/phone.css">
	<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/swiper.min.js"></script>
	<script type="text/javascript" src="js/scrollReveal.js"></script>
	<script src="http://cdn.bootcss.com/jquery.touchswipe/1.6.18/jquery.touchSwipe.min.js"></script>
	<script src="js/bootstrap-touch-slider-min.js"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Diy1GpUowSnG4kyw93KWvG4GfQDm3xch"></script>

	<!-- 地区插件 -->
	<script src="js/distpicker.data.js"></script>	
	<script src="js/distpicker.js"></script>
	<script src="js/main.js"></script>	

	<script type="text/javascript" src="js/jquery.cookie.js"></script>
	<script type="text/javascript" src="js/base64.js"></script>
	<script type="text/javascript" src="js/xiuzhen.js"></script>
	<script>
		if ($(document.body).width() < 760) {
			document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
		} else {
			document.documentElement.style.fontSize = document.documentElement.clientWidth / 1 + 'px';
		}
	</script>
	<!--兼容ie8-->
	<!--[if lt IE 9]>
	    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<!-- 头部导航开始 -->
	<div class="header">
		<div class="nav">
			<img class="logo" src="images/logo.png" alt="">
			<ul class="top">
				<li class="active">
					<a href="javascript:;">首页</a>
				</li>
				<li>
					<a href="list.html">发现社团</a>
				</li>
				<li>
					<a href="new.html">社团快讯</a>
				</li>
				<li>
					<a href="activity.html">社团活动</a>
				</li>
				<li>
					<a href="contact.html">联系我们</a>
				</li>
			</ul>
			<div class="right">
				<a href="login.html" class="login">会员登陆</a>
				<a class="leaguer" href="member.html" style="display: none;">
					<img class="" src="images/people2.png" alt="">
				</a>
				<p id="username" style="display: none;"></p>
			</div>
		</div>
	</div>

	
	<!-- 子页面位置公共样式 -->
	<div class="com-position member-position">
		<p class="container">
			<span>当前页面：</span>
			<a href="index.html">首页</a> >
			<a href="member.html">会员中心</a>
		</p>
	</div>

	<!-- 个人中心页面 -->
	<div class="member">
		<div class="container">
			<div class="left">
				<div class="head">
					<p class="china">会员中心</p>
					<p class="eng">Member Center</p>
				</div>
				<ul class="menu">
					<li><a href="javascript:;" class="active">我的个人资料</a></li>	
					<li><a href="order.html">我的订单</a></li>
					<li><a href="address.html">我的收货地址</a></li>
					<li><a href="editPassword.html">修改密码</a></li>
					<li class="loginOut"><a href="javascript:;">退出</a></li>
				</ul>
			</div>
			<div class="right">
				<div class="title">修改个人资料</div>
				<form action="" id="info">
					<input type="text" class="uid" name="uid" hidden value="">
					<input type="text" class="avatar" name="avatar" hidden value="">
					<div class="personal">
							<div class="top">
								<img class="avatarImg" src="images/headimg.png" alt="">
								<div class="upload">
									<p>上传新的头像</p>
									<input type="file" accept="image/jpeg,image/jpg,image/png" id="avatar">
									<p>允许的文件类型JPG、GIF和PNG，最大文件尺寸为2MB</p>
								</div>
							</div>
							<div class="center">
								<div class="item half">
									<p class="name">用户名</p>
									<input type="text" name="username" class="form-control username" placeholder="">
								</div>
								<div class="item half">
									<p class="name">邮箱</p>
									<input type="text" name="email" class="form-control email" placeholder="">
								</div>
								<div class="item half">
									<p class="name">手机号</p>
									<input type="text" readonly class="form-control phoneNumber" placeholder="" >
								</div>
								<div class="item half">
									<p class="name">新浪微博</p>
									<input type="text" name="sina" class="form-control sina" placeholder="">
								</div>
								<div class="item half">
									<p class="name">微信</p>
									<input type="text" name="wechat" class="form-control wechat" placeholder="">
								</div>
								<div class="item half">
									<p class="name">QQ</p>
									<input type="number" name="qq" class="form-control qq" placeholder="">
								</div>
								<div class="item whole birthday">
									<p class="name">生日</p>
									<input type="date" name="birthday" class="form-control birthday1" placeholder="">
								</div>
								<div class="item whole sex">
									<p class="name">性别</p>
									<label>
										<input type="radio" name="gender" id="woman" value="0">
										女
									</label>
									<label>
										<input type="radio" name="gender" id="man" value="1">
										男
									</label>
								</div>
								<div class="item whole birthday">
									<p class="name">所在地</p>
									<div data-toggle="distpicker" class="distpicker">
										<select id="province" class="form-control" name="province"></select>
										<select id="city" class="form-control" name="city"></select>
										<select id="district" class="form-control" name="district"></select>
									</div>
								</div>
								<div class="item whole work">
									<p class="name">工作行业</p>
									<select class="form-control work" name="work">
										<option value="">请选择您的工作行业</option>
										<option value="技术行业">技术行业</option>
										<option value="行政行业">行政行业</option>
										<option value="教育类">教育类</option>
									</select>
								</div>
							</div>
							<a href="javascript:;" class="preserve">保存</a>
						</div>
				</form>
				
			</div>
		</div>
	</div>

	<!-- 预约弹框样式 -->
	<div class="appointShadow"></div>
	<div class="appoint">
		<p class="close">x</p>
		<p class="title">预约试听课</p>
		<form action="" id="appointment" method="post">
			<div class="form">
				<div class="item">
					<p class="name">孩子姓名</p>
					<input type="text" name="childrenName" class="form-control childrenName" placeholder="填写孩子姓名">
				</div>
				<div class="item">
					<p class="name">孩子年龄</p>
					<input type="text" name="childrenAge" class="form-control childrenAge" placeholder="填写孩子年龄">
				</div>
				<div class="item">
					<p class="name">联系电话</p>
					<input type="text" name="contactTel" class="form-control contactTel" placeholder="填写联系电话">
				</div>
			</div>
			<div class="tigs">
				<p class="tig1">扫码更方便</p>
				<img class="code" src="images/code2.png" alt="">
				<a href="javascript:;" class="make">立即预约</a>
				<p class="tig2">预约成功后，将有工作人员和您联系</p>
			</div>
		</form>
	</div>

	<!-- 右侧弹框 -->
	<div class="rightFrame">
		<div class="bespoke">预约课程</div>
		<div class="placement"><img src="images/top.png" alt="">置顶</div>
	</div>

	<!-- 弹框样式 -->
	<div class="alert-box">
		<span class="xz-alert alert alert-danger"></span>
	</div>

	<!-- 公共底部开始 -->
	<div class="footer">
		<p class="copy">联系电话：18435165567</p>
		<p class="copy">联系邮箱：1056598469@qq.com</p>
		<p class="copy">地址：某某学校知行书院二单元一楼1501教室</p>
	</div>

	

	<script type="text/javascript">
	

		if(!$.cookie('uid')){
			location.href = './index.html';
		}

		var loginUrl = Base64.encode("member.html");  
		$('.header .nav .right .login').attr('href','./login.html?loginurl='+loginUrl);

		// 首页banner
		$('#bootstrap-touch-slider').bsTouchSlider();

		// 点击返回顶部
		$('.rightFrame .placement').on('click', function () {
			$("html,body").animate({
				scrollTop: 0
			}, 1000);
		});

		// 点击预约课程以及点击关闭弹框
		$('.rightFrame .bespoke').on('click', function () {
			$(".appointShadow").css("display","block");
			$(".appoint").css("display","block");
		});	
		$('.appoint .close').on('click', function () {
			$(".appointShadow").css("display","none");
			$(".appoint").css("display","none");
		});


		infoData();
		function infoData(){
			$.ajax({
                type: "get",
                dataType: "", // submit info
                url: url + '/v1/front/user/user/' + $.cookie('uid'),
                success: function (res) {
                    if (!res.resultStatus) {
                        $(".xz-alert").html(res.errorMessage);
                        $('.xz-alert').show();
                        setTimeout(function () {
                            $(".xz-alert").hide();
                        }, 3000);
                        return
					}
					var info = res.resultData;
					$(".username").val(info.username);
					$(".email").val(info.email);
					$(".phoneNumber").val(info.phoneNumber);
					$(".sina").val(info.sina);
					$(".wechat").val(info.wechat);
					$(".qq").val(info.qq);
					$(".birthday1").val(info.birthday);
					if(info.gender == 1){
						$("#man").prop("checked",true);
					}else{
						$("#woman").prop("checked",true);
					}
					$('.distpicker').distpicker('destroy');
					$('.distpicker').distpicker({
					  province: info.province,
					  city: info.city,
					  district: info.district
					});
					
					
					$(".work").val(info.work);	
					$(".avatar").val(info.avatar);	
					if(info.avatar){
						$(".avatarImg").attr('src',info.avatar); 
					}
                },
                error: function (e) {
                    $(".xz-alert").html("请求数据失败");
                    $('.xz-alert').show();
                    setTimeout(function () {
                        $(".xz-alert").hide();
                    }, 3000);
                }
			})
	
		}

		$(function(){
			$(".uid").val(""+ $.cookie('uid') +"");
			// 验证手机号
			function isPhoneNo(phone) {
				var pattern = /^1[34578]\d{9}$/;
				return pattern.test(phone);
			}
			// 验证邮箱
			function isEmail(email) {
				var pattern = /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/;
				return pattern.test(email);
			}


			$("#info .preserve").click(function(){
				if($("#info .userName").val() == ""){
					$(".xz-alert").html("用户名不能为空!");
					$('.xz-alert').show();
					setTimeout(function () {
						$(".xz-alert").hide();
					}, 2000);
				}
				/*else if($("#info .email").val() == ""){
					$(".xz-alert").html("邮箱不能为空!");
					$('.xz-alert').show();
					setTimeout(function () {
						$(".xz-alert").hide();
					}, 2000);
				}else if(isEmail($.trim($("#info .email").val())) == false){
					$(".xz-alert").html("邮箱不正确!");
					$('.xz-alert').show();
					setTimeout(function () {
						$(".xz-alert").hide();
					}, 2000);
				}else if($("#info .birthday1").val() == ""){
					$(".xz-alert").html("生日不能为空!");
					$('.xz-alert').show();
					setTimeout(function () {
						$(".xz-alert").hide();
					}, 2000);
				}*/
				else{
					$.ajax({
						type: "post",
						dataType: "json", // submit info
						url: url + '/v1/front/user/user',
						data:$("#info").serializeArray(),
						contentType:"application/x-www-form-urlencoded",
						success: function (res) {
							if (!res.resultStatus) {
								$(".xz-alert").html(res.errorMessage);
								$('.xz-alert').show();
								setTimeout(function () {
									$(".xz-alert").hide();
								}, 2000);
								return
							}
							$(".xz-alert").html("保存成功！");
							$('.xz-alert').show();
							setTimeout(function () {
								$(".xz-alert").hide();
							}, 2000);
							
						},
						error: function (e) {
							$(".xz-alert").html("请求数据失败");
							$('.xz-alert').show();
							setTimeout(function () {
								$(".xz-alert").hide();
							}, 2000);
						}
				
					})
				}
				
			})

			// 头像上传
			var uploading = false;
			$("#avatar").on("change", function(){
				if(uploading){
					$(".xz-alert").html("文件正在上传中，请稍候");
					$('.xz-alert').show();
					setTimeout(function () {
						$(".xz-alert").hide();
					}, 3000);
					return false;
				}
				var dat = new FormData();
				dat.append('file', $('#avatar').get(0).files[0]);

				$.ajax({
					url: url + '/common/upload',
					type: 'POST',
					cache: false,
					data: dat,
					processData: false,
					contentType: false,
					dataType:"json",
					beforeSend: function(){
						uploading = true;
					},
					success : function(data) {
						if (data.resultStatus) {
							$(".avatarImg").attr('src',data.resultData); 
							$(".avatar").val(data.resultData);
						} else {
							showError(data.errorMessage);
						}
						uploading = false;
					},
					error: function () {
						$(".xz-alert").html("数据加载有误，重新加载中.....");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 2000);
					}

				});
			});
		})

	</script>		

</body>

</html>